<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  User: zhouyanchao
  Date: 2017/10/25
--%>
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
	<base href="${BaseContext}">
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>ajax</title>
	<jsp:include page="include_style.jsp"></jsp:include>

</head>
<body>
<div class="am-container" style="margin-top: 50px;">
	<h1>ajax</h1>
	<button class="am-btn am-btn-primary" id="randomNumBtn">随机加载数字</button>
	<div id="randomNum"></div>

	<button class="am-btn am-btn-default" id="jsonBtn">加载json</button>
	<div id="jsonDiv"></div>


	<button class="am-btn am-btn-default" id="htmlBtn">加载html</button>
	<div id="htmlDiv"></div>
</div>

	<jsp:include page="include_script.jsp"></jsp:include>

	<script>
		$(function () {
			$('#randomNumBtn').click(function () {
				$.get('ajax/random.do',function (result) {
					$('#randomNum').prepend(result);
				});
			});


			$('#jsonBtn').click(function () {
				$.get('ajax/json.do',function (data) {
					console.log(data);

//					alert(data.aa);

					$('#jsonDiv').html(data);
				},'json');
			});

			$('#htmlBtn').click(function () {
			/*	$.get('ajax/html2.do',function (data) {
					console.log(data);
					$('#htmlDiv').html(data);
				},'html');
*/
				$('#htmlDiv').load('ajax/html2.do');

			});


		});
	</script>

</body>
</html>
